﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="OneMG.Phoenix.AdminSite.Views.Links.Index" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">新闻管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadScripts" runat="server">
    <script type="text/javascript" src="/Scripts/m-lhgdialog/m-lhgdialog.js"></script>    

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
            <form id="form1" runat="server">

    <div class="path">
        <a href="/Views/Links/index.aspx"><strong>友情链接</strong></a>
    </div>
    <div class="pd10">
        <div class="mb10 aR">
        <a href="javascript:;" title="新增" class="a-btn1" onclick="OpenPop('/Views/Links/Edit.aspx', '新增友情链接',500,250)">添加链接</a>

        </div>
        
        <span id="Grid">
<table class="tb-list hover">
    <tr>
        <th>
            链接名称
        </th>
        <th>
            链接地址
        </th>
        <th>
            添加时间
        </th>
        <th width="20%">
            操作
        </th>
    </tr>
   <% foreach (OneMG.Phoenix.Service.Model.LinksModel item in listModle) %>
    <%{%>
    <tr>
        <td style="width:40%">
           <%=item.LinkName %>
        </td>        
        <td style="width:20%">
           <%=item.LinkUrl %>
        </td>
         <td style="width:20%">
           <%=item.CreateTime %>
        </td>
        <td style="width:20%">
          <a href="javascript:void(showEdit('<%=item.LinkID %>'))">编辑</a> <a href="javascript:;" onclick="DeleteLinks('<%=item.LinkID %>')">删除</a>

        </td>
    </tr>
<%}%>
</table>
        </span>
            <!-- 分页插件  -->
        <div id="pager" class="aR mt10">
            <webdiyer:AspNetPager ID="AspNetPager1" runat="server" 
                onpagechanged="AspNetPager1_PageChanged" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" UrlPaging="True">
            </webdiyer:AspNetPager>
        </div>

    </div>
    </form>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Scripts" runat="server">

<script type="text/javascript" src="/Scripts/library/m-pagination.js"></script>    
    <script type="text/javascript">
        
        // 删除类目
        function DeleteLinks(linkID) {
            if (confirm("确认删除吗?") == false) {
                return;
            }

            $.ajax({
            url: "/Views/Links/Save.ashx",
            data: { "hdaction": 2, "linkID": linkID },
                type: "POST",
                success: function(data, textStatus) {
                    if (data.status === "warning" || data.status === "error") {
                        alert(data.msg);
                        return false;
                    }
                    // 刷新列表
                    refresh();
                },
                error: function(XmlHttpRequest, textStatus, errorThrown) {
                alert(errorThrown);
                }
            });
        };

        // 显示编辑
        function showEdit(lid) {
            OpenPop('/Views/Links/edit.aspx?lid=' + lid, "编辑友情链接", 500, 250);
        };
        
        //打开弹窗
        function OpenPop(url, titleName, width, height) {
            width = width || 800;
            height = height || 500;
            window.top.winObj = window;
            window.top.oDG = new $.dialog({ id: 'esDialog', title: titleName, page: url, width: width, height: height, btnBar: false, lockScroll: true });
            window.top.oDG.ShowDialog();
        }
        
</script> 
</asp:Content>
